/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package simhya.matheval.function;

/**
 *
 * @author Luca
 */
public class Max extends FunctionDefinition {

    public Max() {
        super.name = "max";
        super.arity = -1;
        super.minimumArity = 2;
        super.maximumArity = Integer.MAX_VALUE;
        super.type = FunctionType.STATIC_ARBITRARY;
        super.randomFunction = false;
    }

    @Override
    public double compute(double x1, double x2) {
        return Math.max(x1, x2);
    }

    @Override
    public double compute(double[] args) {
        double m = Double.NEGATIVE_INFINITY;
        for (int i=0;i<args.length;i++)
            if (args[i] > m)
                m = args[i];
        return m;
    }
}
